/*
 * @Author: funlee
 * @Email: i@funlee.cn
 * @Date: 2018-05-06 10:38:21
 * @Description: 实现透明的单例模式 
 */

const log = console.log.bind();
log('---透明的单例模式 ---');

var CreateDiv = (function () {
  var instance;
  var CreateDiv = function (html) {
    if (instance) {
      return instance;
    }
    this.html = html;
    this.init();
    return instance = this;
  }
  CreateDiv.prototype.init = function () {
    var div = document.createElement('div');
    div.innerHTML = this.html;
    document.body.appendChild(div);
  }
  return CreateDiv;
})();

var a = new CreateDiv('sven1');
var b = new CreateDiv('sven2');
log(a === b);





